<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class StudentSchedule extends CI_Controller {
	
	 public function __construct()
	    {
	        parent::__construct();
			session_start();
	        //$this->output->enable_profiler(FALSE);
	   		if (!isset($_SESSION['uid']) || $_SESSION['uid'] < 1){
		    	redirect('cmemberlogin/requiredmessage','refresh');
		    }
		    else {
		    	if ($_SESSION['role_id'] !=2){
		    		redirect('cmemberlogin/restriction','refresh');
		    	}
		    }
	    }
	    
	public function index()
	{
		$data['title'] = "Student Schedule Management";
		$data['left'] = 'site/admin_department_left';
		$data['main'] = 'site/student_schedulelist';
		$data['schedules'] = $this->MStudentSchedule->getAllStudentSchedule();
		$this->load->vars($data);
		$this->load->view('site/template'); 
	}
	function create(){
		if ($this->input->post('submit')){
	  		$this->MStudentSchedule->addStudentSchedule();
	  		$this->session->set_flashdata('message','Schedule Created');
	  		redirect('studentschedule','refresh');
	  	}
		else{
			$data['title'] = "Add New Student Schedule";
			$data['left'] = 'site/admin_department_left';
			$data['shifts'] = $this->MShift->getShiftDropDown();
			$data['main'] = 'site/student_schedule_create';
			$this->load->vars($data);
			$this->load->view('site/template');    
		} 
	}
	
  function edit($id=0){
  	if ($this->input->post('submit')){
  		$this->MStudentSchedule->updateStudentSchedule();
  		$this->session->set_flashdata('message','Schedule Updated');
  		redirect('studentschedule','refresh');
  	}else{
		$data['title'] = "Edit Student Schedule";
		$data['left'] = 'site/admin_department_left';
		$data['shifts'] = $this->MShift->getShiftDropDown();
		$data['main'] = 'site/student_schedule_edit';
		$data['studentschedule'] = $this->MStudentSchedule->getStudentSchedule($id);
		if (!count($data['studentschedule'])){
			redirect('studentschedule','refresh');
		}
		$this->load->vars($data);
		$this->load->view('site/template');      
	}
  }
  
  function delete($id){
	//$id = $this->uri->segment(4);
	$this->MStudentSchedule->deleteStudentSchedule($id);
	$this->session->set_flashdata('message','Schedule Deleted');
	redirect('studentschedule','refresh');
  }
	
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */